/**
 * Created by HTWX on 2018/3/13.
 */
var express = require('express');
var router = express.Router();

/* GET users listing. */
router.get('/', function(req, res,next) {
    if(req.cookies.submits=='Y')
    {
       res.redirect('/leftresult');
    }
    next();
});
router.get('/', function(req, res) {
    var dt=new Date(req.cookies.start.replace('/', '-'));
    console.log(dt);
    var timespan=dt.getHours()+":"+leftPad(dt.getMinutes(),'0',2-dt.getMinutes().toString().length)+"-";
    var dtt=new Date(dt.setTime(dt.getTime()+1000*60*req.cookies.papertime));
    console.log(dtt);
    var endtime= dtt.getHours()+":"+leftPad(dtt.getMinutes(),'0',2-dt.getMinutes().toString().length);
    var papernames=req.cookies.papername;
    if(papernames.length>15)
    {
        papernames=papernames.substring(0,15);
    }
    res.render('left', {
        title: '医药考试',
        username:req.cookies.username,
        admincard:req.cookies.admincard,
        papername:papernames,
        papertime:timespan,
        endtime:endtime
    });
});

function leftPad(str, c, len) {
    return (Array(len + 1).join(c) + str).substring(str.length);
}

module.exports = router;